tasks.register('sourcesJar', Jar) {
    dependsOn classes
    archiveClassifier = 'sources'
    from sourceSets.main.allSource
}

javadoc.failOnError = false
tasks.register('javadocJar', Jar) {
    dependsOn javadoc
    archiveClassifier = 'javadoc'
    from javadoc
}

artifacts {
    archives sourcesJar, javadocJar
}

apply plugin: 'maven-publish'
publishing {
    publications {
        mavenJava(MavenPublication) {
            artifactId = project.name
            from components.java
            pom {
                name = project.name
                description = 'Extension for Concordion BDD Framework'
                url = 'https://github.com/toronik/exam'

                licenses {
                    license {
                        name = "The Apache Software License, Version 2.0"
                        url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
                    }
                }
                developers {
                    developer {
                        id = "toronik"
                        name = "Nikolai Toropanov"
                        email = "me@toropanov.ru"
                    }
                }
                scm {
                    url = "https://github.com/toronik/exam"
                    connection = 'scm:git:git://github.com/toronik/exam.git'
                    developerConnection = 'scm:git:git://github.com/toronik/exam.git'
                }
            }
        }
    }
}

apply plugin: 'signing'
signing {
    if (project.hasProperty('signingKey') && project.hasProperty('signingPassword')) {
        useInMemoryPgpKeys(project.getProperty('signingKey'), project.getProperty('signingPassword'))
        sign publishing.publications.mavenJava
    }
}

java {
    withSourcesJar()
    withJavadocJar()
}
